import React from 'react'
import moment from 'moment'
// ===================================================================== antd
import { CloseCircleOutlined } from '@ant-design/icons'
// ===================================================================== Temp
import Controls from '#cpt/temp/Controls'
// ===================================================================== declare
const { $fn, $Lazy, $http } = window
// ===================================================================== Lazy
const Form 			= $Lazy.hook(()=>import('@antd/form/layout/form'))
const FormItem 		= $Lazy.load(()=>import('#cpt/form/submit-item'))
const Input 		= $Lazy.load(()=>import('@antd/form/input'))
const Select 		= $Lazy.load(()=>import('@antd/form/select'))
const Table 		= $Lazy.load(()=>import('@antd/table'))
const Button 		= $Lazy.load(()=>import('@antd/button'))
const Box 			= $Lazy.load(()=>import('#tp/box/box'))
const Title 		= $Lazy.load(()=>import('#tp/title/title'))
//
const Charge 		= $Lazy.load(()=>import('./cpt/charge'),1)
const CheckboxModal = $Lazy.state(()=>import('./cpt/checkbox-modal'),1)
const XiafaModal 	= $Lazy.state(()=>import('./cpt/xiafa-modal'),1)
const ChargeModal 	= $Lazy.state(()=>import('./cpt/charge-modal'),1)
const CheckboxRadio = $Lazy.hook(()=>import('./cpt/checkbox-radio'))
const CheckboxRadioJia = $Lazy.hook(()=>import('./cpt/checkbox-radio-jia'))
const IsUpload 		= $Lazy.load(()=>import('./cpt/is-upload'))
const message 		= $Lazy.file(()=>import('@antd/message'))
//
const PrinterSetModal = $Lazy.state(()=>import('#private/pages/printer-set-modal'),1)
// 44011
const FirstStopReportModal = $Lazy.state(()=>import('./cpt/first-stop-report-modal'),1)
// public
const Submit 		= $Lazy.file(()=>import('#cpt/temp/js/onSubmit'))
const PreviewAuditReport 	= $Lazy.file(()=>import('@views/_public/preview-audit-report/js/utils'))
// ===================================================================== component
const fixedData = [
	{ name:'固定不佳', value:'50201'},
	{ name:'酒精固定', value:'50202'},
	{ name:'未固定', value:'50203'}
]
const cols = [
	{ title: '名称', 		dataIndex: 'item_name' },
	{ title: '参考价', 		dataIndex: 'price', width:100 }
]
const reportData = [ {name:'阳性', value:'1'}, {name:'阴性', value:'2'} ]
// ===================================================================== component
const Index = ({ rows, mode, result, disabled, query, doctor=[], record=[], yaoSelect=[], resultSelect=[], info={}, onRefresh, onRefreshInfo, submitLoading,  _this, isBingLi, status }, ref) => {
	const formRef = React.useRef()
	const checkboxModalRef =  React.useRef()
	const xiafaModalRef =  React.useRef()
	const [ xia, setXia ] = React.useState()
	const [ loading, setLoading ] =  React.useState(false)
	const [ scale, setScale ] = React.useState(1)
	const printerSetModal = React.useRef()
	const chargeModal = React.useRef()
	const checkboxRadioRef = React.useRef()
	const checkboxRadioJiaRef = React.useRef()
	const firstStopReportModal = React.useRef()
	const clear = React.useRef()
	const [ item, setItem ] = React.useState([])
	const [ positive, setPositive ] = React.useState() // 是否为阳性
	
	const get44011Cols = React.useCallback(()=>{
		return [
			{ title: '名称', 		dataIndex: 'drug_name', render: (text, {uuid}) => {
				return (
					<div className='fxm'>
						<span className='cp lh' onClick={()=>{
							setItem( item => {
								const index = item.findIndex( v => v.uuid === uuid)
								item.splice(index, 1)
								return [...item]
							})
						}}><CloseCircleOutlined style={{fontSize:16, color:$fn.c0}} /></span>
						<span className='ml5'>{text}</span>
					</div>
				)
			} },
			{ title: 'MIC', 		dataIndex: 'mic', 		render: (text, rows) => <Input p='请输入' value={text} onChange={value=> rows.mic = value } /> },
			{ title: 'K-B', 		dataIndex: 'kb', 		render: (text, rows) => <Input p='请输入' value={text} onChange={value=> rows.kb = value } /> },
			{ title: '结果', 		dataIndex: 'result', 	render: (text, rows) => <Select size='small' bordered p='请选择' value={text} onChange={value=> rows.result = value } data={resultSelect} /> }
		]
	},[ resultSelect ])
	
	const get44012Cols = React.useCallback(()=>{
		return [
			{ title: '药敏名称', dataIndex: 'drug_name', render:(text, {uuid}) => {
				return (
					<div className='fxm'>
						<span className='cp lh' onClick={()=>{
							setItem( item => {
								const index = item.findIndex( v => v.uuid === uuid)
								item.splice(index, 1)
								return [...item]
							})
						}}><CloseCircleOutlined style={{fontSize:16, color:$fn.c0}} /></span>
						<span className='ml5'>{text}</span>
					</div>
				)
			}},
			{ title: '结果', 		dataIndex: 'result', 	render: (text, rows) => <Select size='small' bordered p='请选择' value={text} onChange={value=> rows.result = value } data={resultSelect} /> }
		]
	},[ resultSelect ])
	
	// 设置回显值
	const setValue = React.useCallback(() => {
		formRef.current?.refs?.ref?.reset()
		const { content, price: realPrice = 0 } = info
		if(formRef.current && $fn.hasObject(content)){
			/* ======================================= 44021 =======================================*/
			// 新增44033模型 2022/8/9 --马婷
			let price = 0
			let newTime = null
			if(mode === 44021 || mode === 44033){
				const { qt_item_table, time } = content
				if(mode === 44021){
					if($fn.hasArray(qt_item_table)){
						setItem(qt_item_table)
						price = qt_item_table.reduce((total,value) => total + +value.price, 0)
					}else{
						setItem([])
					}
					price = price.toFixed(2)
				}
				const nowTime = moment().format("YYYY-MM-DD HH:mm:ss")
				newTime = (time && moment().isBefore(time) ? nowTime : time) || nowTime
			}else if( mode === 44011 || mode === 44012 || mode === 44020){
				const { drug_table, first_check, check } = content
				
				setPositive( +first_check === 1 || +check === 1 )
				
				if($fn.hasArray(drug_table)){
					setItem(drug_table)
				}else{
					setItem([])
				}
				
			} else if (mode === 44029 && content) {
				// 细胞涂片岗 增加默认显示字段 [2021-8-10 4:29:59 ?F10: PM?] --伍智睿
				content.pathological_diagnosis = content.pathological_diagnosis ?? '未见上皮内病变或恶性病变（NILM）。'
				content.send_material = content.send_material ?? '宫颈脱落细胞'
			}
			/* --------------------------------------- end --------------------------------------- */
			formRef.current.refs.ref.setValue({fees: parseFloat(realPrice), item_num:1, total_price: realPrice, ...content, price, time: newTime??content.time})
		}else{
			if( mode===44021 || mode === 44011 || mode === 44012 || mode === 44020 || mode===44033){
				setItem([])
				setPositive( false )
			}
			
			if(mode === 44022){
				// 免疫组化 修改默认价格为120 [2022-3-22 16:28:25 ?F10: PM?] --伍智睿
				formRef?.current?.refs?.ref?.setValue?.({fees: parseFloat(realPrice), item_num: 1, total_price: realPrice})
			}
			// 细胞涂片岗 增加默认显示字段 [2021-8-10 4:08:25 ?F10: PM?] --伍智睿
			if(mode === 44029 && content){
				formRef?.current?.refs?.ref?.setValue?.({pathological_diagnosis: '未见上皮内病变或恶性病变（NILM）。', send_material: '宫颈脱落细胞'})
			}
		}
	},[ mode, info, formRef ])
	
	// 下发
	const xiFaSend = React.useCallback(({device_number, experiment_num}) => {
		const { result_model } = info
		clearInterval(clear.current)
		let count = 0
		// 新增44032 20211102 耿琰
		if([44013, 44021, 44022, 44008, 44032, 44033 ].includes(+result_model)){
			setLoading(true)
			clear.current = setInterval(()=>{
				$http.submit(null, 'ts-report-card/checkBingliImgsUpdateCount', { param:{ device_number, experiment_num, type:1 }, loading:false, onError:()=>{
					clearInterval(clear.current)
					setLoading(false)
				} }).then(({ is_refresh, imgs_count })=>{
					imgs_count = +imgs_count
					is_refresh = +is_refresh
					if( is_refresh > 0 || (imgs_count > 0 && count !== imgs_count) ){
						message.then(f => f.success('下发成功'))
						onRefreshInfo()
					}else if( is_refresh === -1 || imgs_count === -1 ){
						message.then(f => f.warning('已过期，请重新下发', 30000))
						clearInterval(clear.current)
						setLoading(false)
					}
					count = imgs_count
				})
			},2000)
		}
	}, [info, onRefreshInfo])
	
	React.useImperativeHandle( ref, () => {
		return {
			xiFaSend: experiment_num => {
				if(xia){
					const device_number = $fn.local('xiafa')
					if(device_number && loading){
						clearInterval(clear.current)
						$http.submit(null,'ts-report-card/bingliImgconf', { param:{ experiment_num, type:1, device_number }}).then(data=>{
							xiFaSend({ device_number, experiment_num })
						})
					}
				}
			}
		}
	})
	
	React.useEffect( () => {
		return () => {
			clearInterval(clear.current)
		}
	},[])
	
	const init = React.useCallback( form => {
		setValue()
		if(checkboxRadioRef.current){
			checkboxRadioRef.current?.refs?.ref?.load(formRef.current.refs.ref)
		}else if(checkboxRadioJiaRef.current){
			checkboxRadioJiaRef.current?.refs?.ref?.load(formRef.current.refs.ref)
		}
	},[setValue])
	
	// 公共操作按钮
	const controls = React.useCallback(() => {
		const { content, uuid, result_model, spec_code, experiment_num, report } = info || {}
		// 添加判断只有statu ===45001显示【审核、批准、终止】按扭 2022-5-10  --马婷
		const _show_1 = mode===44011 && content  && content.first_check && (content.is_first_report_audit === '' || !content.is_first_report_audit) && +status === 45001
		const _show_2 = mode===44011 && content && content.is_first_report_audit
		const _show_3 = mode===44011 && content && content.is_first_report_audit && +status === 45001
		const _show_4 = mode===44011 && [45003, 45004, 45006, 45007,45008].includes(status) ? false : true
		return [
			// 新增44032 20211102 耿琰
			([44013, 44021, 44022, 44008, 44032, 44033 ].includes(mode)) && Controls.click('下发设置', () => { xiafaModalRef.current.refs.ref.open() }, {disabled}),
			([44013, 44021, 44022, 44008, 44032, 44033 ].includes(mode)) && Controls.click( loading ? '停止下发' : '下发', () => {
				if(!loading){
					const device_number = $fn.local('xiafa')
					if(device_number){
						$http.submit(null,'ts-report-card/bingliImgconf', { param:{ experiment_num, type:1, device_number }}).then(data=>{
							setXia(true)
							xiFaSend({ device_number, experiment_num})
						})
					}else{
						xiafaModalRef.current.refs.ref.open()
					}
				}else{
					setLoading(false)
					clearInterval(clear.current)
				}
			}, {disabled}),
			_show_4 && Controls.click('保存', () => { formRef.current.refs.ref.submit() },{
				disabled,
				code:'F2',
				tip: () => $fn.hasObject(info) ? true : '请先选择项目列表一条数据'
			}),
			// 44011
			_show_1 && Controls.submit('审核初次报告', 'ts-report-card/firstreport',{ // 保存初次检验结果时显示审核按钮 
				disabled,
				tip: () => $fn.hasObject(info) ? true : '请先选择项目列表一条数据',
				param : () => ( { result_model, uuid, status:info.status} ),
				onRefresh:onRefresh.bind(null),
			}),
			_show_3 && Controls.submit('批准初次报告', 'ts-report-card/firstapprove',{
				disabled: (mode===44011 && $fn.hasObject(report) && (+report.status===95)) ? true : disabled,		// 第一次批准后禁用掉按钮 2022-5-10  --马婷
				tip: () =>$fn.hasObject(info) ? true : '请先选择项目列表一条数据',
				param : () => ( { uuid, report_num:content.is_first_report_approval||content.is_first_report_audit } ),
				onRefresh:onRefresh.bind(null),
			}),
			_show_3 && Controls.click('终止初次报告', ()=>{ firstStopReportModal.current.refs.ref.open({uuid, project_id:query.project_id}) },{
				disabled,
				tip: () => $fn.hasObject(info) ? true : '请先选择项目列表一条数据',
				param : () => ( { result_model, uuid, status:info.status} ),
				onRefresh:onRefresh.bind(null),
			}),
			_show_2 && Controls.click('预览初次报告单',()=>{
				const { is_first_report_audit } = content
				PreviewAuditReport.then(f => f.call(_this,{ spec_num:is_first_report_audit, spec_code, uuid, result_model, audit:0 }))
			})
		]
	},[disabled, mode, info, query, onRefresh, _this, xiFaSend, loading, status])
	/* ===================== 打印按钮 44021  ===================== */
	const printControls = React.useCallback(() => {
		return (mode === 44021 || mode === 44033) ? [
			Controls.printer({ label:'打印', code:50105, disabled, data:()=>{
				const { ref } = formRef.current.refs
				const naked_eye = ref.getName('naked_eye')					// 肉眼所见
				const wax_block_number = ref.getName('wax_block_number')	// 蜡块数量
				const time = ref.getName('time')							// 时间
				// 取材医生
				const arr1 = doctor.filter( v=> v.value ===  ref.getName('draw_materials_doctor_id'))
				const _doctor = $fn.hasArray(arr1) ? arr1[0].name : ''
				// 记录人
				const arr2 = record.filter( v=> v.value ===  ref.getName('record_id'))
				const _record = $fn.hasArray(arr2) ? arr2[0].name : ''
				return `
肉眼所见：${naked_eye??''}
蜡块数量：${wax_block_number??'1'}
取材医生：${_doctor}
记录人：${_record}
时间：${time??''}
				`
			} })
		] : []
	},[disabled, mode, doctor, record ])
	// 提交保存
	const onSubmit = React.useCallback( (param, callback) => {
		// const _rows = $fn.getSelectedRows(rows)
		// const charge = chargeRef ? chargeRef.current.refs.ref.getValue() : null
		let _44008 = {}
		let _44011 = {}
		let _44021 = {}
		// let _44032 = {}
		// 新增44032 20211102 耿琰
		if( mode === 44008 || mode === 44032 ){
			let { list, web } = checkboxRadioRef.current.refs.ref.data()
			let forms_check_data_web = { line_1:[], line_1_1:[], line_2:[], line_3:[], line_7:[], line_7_1:[], line_10:[], line_10_1:[]}
			if(mode === 44032) {
				forms_check_data_web = { line_1:[], line_1_1:[], line_2:[], line_3:[], line_4:[], line_5:[], line_6:[] }
			}
			list  = $fn.copy(list)
			
			for(let i in param){
				list.forEach(p=>{
					if( p.name && p.name === i && param[i] === true ){
						p.value = i
					}
				})
			}
			let forms_check_data = [{'3-1-2':''}]
			if( mode === 44032 ){ forms_check_data= []  }
			list.forEach(({ value, label, name, line}) => {
				if(name){
					if(value){
						// forms_check_data[name] = label
						forms_check_data_web[line].push(name)
					}
					forms_check_data.push({[name] : value ? label : ''})
				}
			})
			
			for(let i in param){
				if(/^[0-9]/.test(i)){
					delete param[i]
				}
			}
			_44008 = { ...param, forms_check_data, forms_check_data_web:JSON.stringify(forms_check_data_web), regroup_data_web: JSON.stringify(web)  }
			// _44032 = { ...param, forms_check_data_web:JSON.stringify(forms_check_data_web), regroup_data_web: JSON.stringify(web)  }
		}else if( mode === 44011 || mode === 44012 || mode === 44020 ){
			_44011 = positive ? { drug_table :item } : null
			if( mode === 44011 ){
				_44011 = { ..._44011, operation_44011: info.operation_44011}
			}
		}else if( mode === 44021){
			_44021 = { qt_item_table: $fn.hasArray(item) ? item : '' }
		}
		
		Submit.then(f => {
			const { status, result_model, uuid } = info
			f({
				msg:'保存',
				api:'result-unit-item/update',
				param:{ dmodel:result_model, status: status, uuid, content: {...param, ..._44021, ..._44008, ..._44011 },  },
				onRefresh: ()=>{
					if(mode === 44011){
						onRefresh()
					}
					callback?.()
				}
			})
		})
		
		if(mode === 44021 || mode === 44033){
			const { project_id } = $fn.getCenterQuery()
			const { draw_materials_doctor_id, record_id} = param
			window.$http.submit(null,'ts-report-card/bingLiSave', { param:{project_id, draw_materials_doctor_id, record_id } })
		}
	},[ mode, item, info, positive, onRefresh ])
	
	const getPositive = React.useCallback(()=>{
		setTimeout(()=>{
			const { first_check, check } = formRef.current.refs.ref.getValue()
			setPositive( +first_check === 1 || +check === 1  )
		})
	},[])
	
	const row = 3
	
	const _search = { i:0 }	// 病理所见、肉眼所见、病理诊断
	
	// 动态获取 kind_id [2021-7-27 5:38:16 ?F10: PM?] --伍智睿
	const _search0 = { i:1, p:{type:0, kind_id: info?.kind_category === '25002' ? info?.parent_kind_id : info?.kind_id} }	// 结果
	const _search2 = { i:1, p:{type:2, kind_id: info?.kind_category === '25002' ? info?.parent_kind_id : info?.kind_id} }	// 、建议与解释
				
	
	const imgs						= <IsUpload info={info} disabled={disabled} multiple />
	const send_material 			= <FormItem title='送检材料' name='send_material' wrapClassName='big-font' disabled={disabled} />
	const clinical_diagnosis 		= <FormItem title='临床诊断' name='clinical_diagnosis' disabled={disabled} />
	const wax_block_number 			= <FormItem title= {mode === 44022 ? '原蜡块号' : '蜡块数量'} isP name='wax_block_number' disabled={disabled} />
	const pathology 				= <FormItem title='病理所见' name='pathology' rows={row} mode='textarea' disabled={disabled} search={_search} form={formRef}/>
	const naked_eye 				= <FormItem title='肉眼所见' name='naked_eye' wrapClassName='big-font' rows={row} mode='textarea' disabled={disabled} search={_search} form={formRef} controls={printControls()}/>
	const pathological_diagnosis 	= (
		<div className={scale === 2 ? 'scale-big-box' : ''}>	
			<FormItem title='病理诊断' name='pathological_diagnosis' wrapClassName='big-font' rows={row} mode='textarea' disabled={disabled} search={_search} form={formRef}
			controls={ (mode === 44021 || mode === 44022 ||mode === 44033) ? [
				Controls.click('', () => { 
					setScale( scale => scale === 1 ? 2 : 1)
				}, {disabled, scale}),
				Controls.click('选择', () => { checkboxModalRef.current.refs.ref.open() }, {disabled}),
			] : [] }/>
		</div>
	)
		
	const _40411_disabled = mode === 44011 && info?.operation_44011 === 'FL1000810001' && Boolean(result?.is_first_report_audit)
	return (
		<>
			<Box full flex scroll title='实验结果' scrollClassName='plr10 pb10' className='ex' controls={controls()} loading={submitLoading}>
				<Form onSubmit={onSubmit} className='submit-form middle-form wh' ref={formRef} init={init} style={{minWidth:500}}>
					{
						(mode === 44013 || mode === 44029 || mode === 44030) && (
							<>
								{ mode === 44013 &&  imgs }
								<div className='fx'>
									<div className='ex fv xj'>
										{ send_material } {/* 送检材料 */}
										{ clinical_diagnosis } {/* 临床诊断 */}
									</div>
									<div className='ex ml10'>{ pathology }</div> {/* 病理所见 */}
								</div>
								<div className='fx'>
									<div className='ex'>{ naked_eye }</div> {/* 肉眼所见 */}
									<div className='ex ml10'>{ pathological_diagnosis }</div>{/* 病理诊断 */}
								</div>
							</>
						)
					}
					{
						mode === 44022 && (
							<>
								{ imgs }
								<div className='fx'>
									<div className='ex fv xj'>
										{ clinical_diagnosis }{/* 临床诊断 */}
										{ wax_block_number }{/* 蜡块数量 */}
									</div>
									<div className='ex ml10'>{ pathology }</div> {/* 病理所见 */}
								</div>
								<div className='fx'>
									<div className='ex'>{ naked_eye }</div> {/* 肉眼所见 */}
									<div className='ex ml10'>{ pathological_diagnosis }</div>{/* 病理诊断 */}
								</div>
								<Charge form={formRef} disabled={disabled} result={result}/>
							</>
						)
					}
					{
						(mode === 44021 || mode === 44033) && (
							<>
								<div className='fx pb5'>
									<div className='ex'>
										<div className='fx'>
											<FormItem title='固定时间' name='fixed_time' wrapClassName='ex' after disabled={disabled} type='date-time' format={2} />
											<FormItem title='离体时间' name='in_vitro_time' wrapClassName='ex ml10' after disabled={disabled} type='date-time' format={2} />
										</div>
										{ send_material } {/* 送检材料 */}
										{ clinical_diagnosis } {/* 临床诊断 */}
										{ naked_eye } {/* 肉眼所见 */}
										<div className='fx'>
											<FormItem title='固定情况' wrapClassName='mr10 ex' name='fixed' disabled={disabled} type='select' data={fixedData}
												onChanged={({ rows })=>{
													const v = formRef.current.refs.ref.getName('naked_eye')
													const naked_eye = v ? v + '\r' + rows['name'] : rows['name']
													formRef.current.refs.ref.setValue( { naked_eye } )
												}}
											/>
											<div className='ex'>{ wax_block_number }</div> {/* 蜡块数量 */}
										</div>
										<div className='fx'>
											<FormItem title='取材医生' wrapClassName='mr10 ex' name='draw_materials_doctor_id' disabled={disabled} type='select' data={doctor}/>
											<FormItem title='记录人' wrapClassName='ex' name='record_id' disabled={disabled} type='select' data={record}/>
										</div>
										<div className='fx'>
											{mode === 44021 && <div className='fxm ex xb'>
												<FormItem title='收费' wrapClassName='mr5 ex' name='price' disabled={true}/>
												<Button className='rel' style={{top:-3}} label='收费' size='small' disabled={disabled} onClick={()=>{
													chargeModal.current.refs.ref.open(item, info)
												}} />
											</div>}
											<FormItem title='时间' wrapClassName={mode === 44021?'ex ml10':'ex'} name='time' after disabled={disabled} type='date-time' />
										</div>
										{ mode === 44021 &&<Table space='h5' wrapClassName='mt10' hasBottom={false} wrapStyle={{height:208}} size='small' data={item} isIndex  cols={cols} />}
									</div>
									<div className='ex ml10'>
										{ imgs } {/* 图片 */}
										{ pathology } {/* 病理所见 */}
										{ pathological_diagnosis } {/* 病理诊断 */}
									</div>
								</div>
								
								{/* 打印弹窗*/}
								<PrinterSetModal  ref={printerSetModal} />
								{/* 收费弹窗 */}
								<ChargeModal ref={chargeModal} onSelect={ (price, data) => {
									setItem(data)
									formRef.current.refs.ref.setValue({ price })
								} } />
							</>
						)
					}
					{
						mode === 44008 && <CheckboxRadio ref={checkboxRadioRef} info={info} result={result} form={formRef} disabled={disabled} />
					}
					{/* 新增44032 20211102 耿琰 */}
					{
						mode === 44032 && <CheckboxRadioJia ref={checkboxRadioRef} info={info} result={result} form={formRef} disabled={disabled} />
					}
					{
						mode === 44011 && (
							<>
								<div className='fx'>
									<IsUpload info={info} disabled={disabled} />
									<div className='ex'>
										<Title title='初步报告' className='mb5' />
										<FormItem name='first_check' type='radio' disabled={disabled || _40411_disabled} data={reportData} onChanged={getPositive} />
										<FormItem title='建议与解释' name='first_suggestion_name' mode='textarea' disabled={disabled || _40411_disabled } search={_search2} form={formRef}/>
										<FormItem title='结果' name='first_result' mode='textarea' disabled={disabled || _40411_disabled} search={_search0} form={formRef}/>
									</div>
									{/* 最终报告 */}
									{
										info?.operation_44011 === 'FL1000810001' && (
											<div className='ex ml10'>
												<Title title='最终报告' className='mb5' />
												<FormItem name='check' type='radio' disabled={disabled} data={reportData} onChanged={getPositive}/>
												<FormItem title='建议与解释' name='result_suggestion_name' mode='textarea' disabled={disabled} search={_search2} form={formRef}/>
												<FormItem title='结果' name='result' mode='textarea' disabled={disabled} search={_search0} form={formRef}/>
											</div>
										)
									}
								</div>
								{/* 阳性时显示 */}
								{
									positive && (
										<>
											<div className='fxm'>
												<FormItem title='药敏组合' wrapClassName='ex mr10' name='dis_code' disabled={disabled} type='select' data={yaoSelect} nameStr='group_name' onChanged={({value, rows})=>{
													if(rows){
														window.$http.pull(null,'drug-sensitivity/senslist', { param:{group_id:value, group_num:rows.group_num}, loading:true}).then(data=>{
															setItem(item => $fn.onlyObject([...item, ...data], 'uuid') )
														})
													}else{
														// setItem([])
													}
												}} />
												<FormItem title='菌落计数' wrapClassName='ex' name='count' disabled={disabled} />
											</div>
											<Table space='h5' wrapClassName='mt10' wrapStyle={{height:600}} size='small' data={item}  cols={get44011Cols()} />
										</>
									)
								}
								<FirstStopReportModal ref={firstStopReportModal} onRefresh={onRefresh} />
								{/*添加审核人、批准人及时间 2022-5-10  --马婷*/}
								<div className='fx' style={{width:'50%'}}>
									{info?.content?.first_report_audit_real_name && <FormItem title='审核人' value={info?.content?.first_report_audit_real_name} p='' disabled wrapClassName='ex mr10'/>}
									{info?.content?.first_report_audit_at&&<FormItem title='审核时间' value={info?.content?.first_report_audit_at} p='' disabled wrapClassName='ex'/>}
								</div>
								<div className='fx' style={{width:'50%'}}>
									{info?.content?.first_report_approval_real_name&&<FormItem title='批准人' value={info?.content?.first_report_approval_real_name} p='' disabled wrapClassName='ex mr10'/>}
									{info?.content?.first_report_approval_at&&<FormItem title='批准时间'value={info?.content?.first_report_approval_at} p='' disabled wrapClassName='ex'/>}
								</div>
							</>
						)
					}
					{
						(mode === 44012 || mode === 44020) && (
							<>
								<div className='fxm'>
									<FormItem name='check' wrapClassName='ex pt10' type='radio' disabled={disabled} data={reportData} onChanged={({value})=>setPositive( +value === 1)}/>
									<IsUpload className='ex ml10' info={info} disabled={disabled} multiple />
								</div>
								<div className='fx'>
									<FormItem wrapClassName='ex' title='建议与解释' name='result_suggestion_name' mode='textarea' disabled={disabled } search={{ i:1, p:{type:2, kind_id:info?.kind_id }}} form={formRef}/>
									<FormItem wrapClassName='ex ml10' title='结果' name='result' mode='textarea' disabled={disabled} r search={{ i:1, p:{type:0, kind_id:info?.kind_id}}} form={formRef}/>
								</div>
								{/* 阳性时显示 */}
								{
									positive && (
										<>
											<div className='fx'>
												<div className='ex mr10'>
													<FormItem title='药敏组合' name='dis_code' disabled={disabled} type='select' data={yaoSelect} nameStr='group_name' onChanged={({value, rows})=>{
														if(rows){
															window.$http.pull(null,'drug-sensitivity/senslist', { param:{group_id:value, group_num:rows.group_num}, loading:true}).then(data=>{
																setItem(item => $fn.onlyObject([...item, ...data], 'uuid') )
															})
														}else{
															// setItem([])
														}
													}} />
												</div>
												<FormItem title='菌落计数' name='count' wrapClassName='ex' disabled={disabled} />
											</div>
											{ mode === 44012 && <Table space='h5' wrapClassName='mt10' wrapStyle={{height:600}} size='small' data={item}  cols={get44012Cols() } /> }
											{ mode === 44020 && <Table space='h5' wrapClassName='mt10' wrapStyle={{height:600}} size='small' data={item} cols={get44011Cols() } /> }
										</>
									)
								}
								
							</>
						)
					}
				</Form>
			</Box>
			{/* 病理诊断选择 */}
			{ (mode === 44013 || mode === 44029 || mode === 44030 || mode === 44022 || mode === 44021 || mode === 44033)  && <CheckboxModal rows={rows} form={formRef} type={query?.type} ref={checkboxModalRef} /> }
			{/* 下发设置 */}
			{ (mode === 44013 || mode === 44021 || mode === 44022 || mode === 44008 || mode === 44032 || mode === 44033) && <XiafaModal ref={xiafaModalRef} info={info} query={query}/> }
		</>
	)
}
const _ =  React.forwardRef(Index)
export default _